<template>
  <a-config-provider :locale="locale">
    <div id="app">
      <router-view/>
    </div>
  </a-config-provider>
</template>
<script>
  import en_US from 'ant-design-vue/es/locale-provider/en_US'
  import zh_CN from 'ant-design-vue/es/locale-provider/zh_CN'
  import enquireScreen from '@/utils/device'
  import Vue from 'vue'
  export default {
    data () {
      return {
        locale: zh_CN,
      }
    },
    created () {
      let that = this
      enquireScreen(deviceType => {
        // tablet
        if (deviceType === 0) {
          that.$store.commit('TOGGLE_DEVICE', 'mobile')
          that.$store.dispatch('setSidebar', false)
        }
        // mobile
        else if (deviceType === 1) {
          that.$store.commit('TOGGLE_DEVICE', 'mobile')
          that.$store.dispatch('setSidebar', false)
        }
        else {
          that.$store.commit('TOGGLE_DEVICE', 'desktop')
          that.$store.dispatch('setSidebar', true)
        }

      })
        if(Vue.ls.get('language')=='zh-CN'){
            that.locale=zh_CN;
            that.$i18n.locale = 'zh-CN';
        }else  if(Vue.ls.get('language')=='en-US'){
            that.locale=en_US;
            that.$i18n.locale = 'en-US';
        }else{
            that.locale=zh_CN;
            that.$i18n.locale = 'zh-CN';
        }

    },
      watch:{
        '$i18n.locale'(){
            var that=this;
            if(Vue.ls.get('language')=='zh-CN'){
                that.locale=zh_CN;
            }else  if(Vue.ls.get('language')=='en-US'){
                that.locale=en_US;
            }
        }
      },

  }
</script>
<style>
  #app {
    height: 100%;
  }
</style>